package com.example.recordingpen_datacollection.AIBDText;

public class NewLineCheck {
    public static void main(String[] args) {  
        String text1 = "This is a string with a newline:\nAnd here is the new line.";  
        String text2 = "This string has a Windows-style newline:\r\nAnd the new line follows.";  
        String text3 = "This string has no newline.";  
  
        // Check for Unix/Linux-style newline (\n)  
        boolean hasUnixNewline1 = text1.contains("\n");  
        boolean hasUnixNewline2 = text2.contains("\n"); // This will be false for \r\n  
        boolean hasUnixNewline3 = text3.contains("\n");  
  
        // Check for Windows-style newline (\r\n)  
        boolean hasWindowsNewline1 = text1.contains("\r\n"); // This will be false for \n  
        boolean hasWindowsNewline2 = text2.contains("\r\n");  
        boolean hasWindowsNewline3 = text3.contains("\r\n");  
  
        // Output the results  
        System.out.println("text1 has Unix newline: " + hasUnixNewline1);  
        System.out.println("text2 has Unix newline: " + hasUnixNewline2);  
        System.out.println("text3 has Unix newline: " + hasUnixNewline3);  
  
        System.out.println("text1 has Windows newline: " + hasWindowsNewline1);  
        System.out.println("text2 has Windows newline: " + hasWindowsNewline2);  
        System.out.println("text3 has Windows newline: " + hasWindowsNewline3);  
  
        // Alternatively, you can use a regex to check for either type of newline  
        boolean hasAnyNewline1 = text1.matches(".*(\\r?\\n).*");  
        boolean hasAnyNewline2 = text2.matches(".*(\\r?\\n).*");  
        boolean hasAnyNewline3 = text3.matches(".*(\\r?\\n).*");  
  
        // Output the regex results  
        System.out.println("text1 has any newline (regex): " + hasAnyNewline1);  
        System.out.println("text2 has any newline (regex): " + hasAnyNewline2);  
        System.out.println("text3 has any newline (regex): " + hasAnyNewline3);  
    }  
}